package com.world.business.weapon.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.world.business.weapon.domain.WeaponChangeLog;
import com.world.business.weapon.domain.query.WeaponChangeLogAddRequest;
import com.world.business.weapon.mapper.WeaponChangeLogMapper;
import com.world.business.weapon.service.IWeaponChangeLogService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 装备变更记录 服务实现类
 * </p>
 *
 * @author 邓驴
 * @since 2023-09-05
 */
@Service
public class WeaponChangeLogServiceImpl extends ServiceImpl<WeaponChangeLogMapper, WeaponChangeLog> implements IWeaponChangeLogService {

    @Override
    public List<WeaponChangeLog> get(Long weaponId) {
        LambdaQueryWrapper<WeaponChangeLog> queryWrapper = Wrappers.lambdaQuery(WeaponChangeLog.class);
        queryWrapper.eq(WeaponChangeLog::getWeaponId, weaponId);
        return this.baseMapper.selectList(queryWrapper);
    }

    @Override
    public Long add(WeaponChangeLogAddRequest request) {
        WeaponChangeLog weaponChangeLog = BeanUtil.copyProperties(request, WeaponChangeLog.class);
        this.baseMapper.insert(weaponChangeLog);
        return weaponChangeLog.getId();
    }

}
